package com.runoob.thread_exec;

import java.util.Arrays;

public class GuessTest {

    public static void main(String[] args) {
        Runnable hello = new DisplayMessage("Hello");
        Thread thread1 = new Thread(hello);
        thread1.setDaemon(true); // 将该线程标记为守护线程或用户线程
        thread1.setName("hello"); // 改变线程名称，使之与参数 name 相同。
        System.out.println("starting hello thread1 ... ");
        thread1.start(); // 使该线程开始执行；Java 虚拟机调用该线程的 run 方法。

        Runnable bye = new DisplayMessage("GoodBye");
        Thread thread2 = new Thread(bye);
        thread2.setPriority(Thread.MIN_PRIORITY); // 更改线程的优先级。
        thread2.setDaemon(true);
        System.out.println("starting bye thread2 ... ");
        thread2.start();

        System.out.println("starting thread3 ... ");
        Thread thread3 = new GuessANumber(27); // 猜数字游戏
        thread3.start();
        try {
            thread3.join(); // 等待该线程终止的时间最长为 millis 毫秒
        } catch (InterruptedException e) {
            System.out.println("Thread interrupted.");
        }

        System.out.println("starting thread4 ... ");
        Thread thread4 = new GuessANumber(75);
        thread4.start();

        System.out.println("... end ... ");
    }
}
